# -*- coding: utf-8 -*-
import scrapy
from scrapys.items import ChinadrugtrialsItem


class ChinadrugtrialsSpider(scrapy.Spider):
    name = 'chinadrugtrials'
    allowed_domains = ['chinadrugtrials.org.cn']
    def start_requests(self):
        start_urls = ['http://www.chinadrugtrials.org.cn/eap/11.snipet.block']
        for url in start_urls:
            yield scrapy.Request(url=url, callback=self.parse, meta={'proxy': 'http://124.207.82.166:8008'})

    def parse(self, response):
        item = ChinadrugtrialsItem()
        lis = response.xpath('//div[@class="question"]')
        
        item['history'] = lis.xpath('//div[@class="about_title"]/text()').extract()[0:8]
        item['people'] = lis.xpath('//div[@class="about_title"]/text()').extract()[8:9]
        item['mess'] = lis.xpath('//div[@class="about_title"]/text()').extract()[9:10]

        yield item
        pass
